package com.rsk.utils.common;


import java.util.HashMap;
import java.util.Map;

/**
 * 非空校验工具类1.0
 * @author mayangrui
 *
 * @version 1.0
 */
public class ValidatorUtils {

    //public static Pattern phoneNumPattern = Pattern.compile("^1[0-9]{10}$");
   // public static Pattern emailPattern = Pattern.compile("^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w{2,3}){1,2})");
   // public static Pattern zeroPattern = Pattern.compile("[0](\\s|\\S)*");

    Map<String,Object> map = new HashMap<>();

    /**
     * 验证参数是否为NULL
     */

    public  boolean isNull(Object o) {
        return null == o;
    }

    public  boolean stringIsEmpty(String o){
        return isNull(o) || 0 == o.length();
    }

    public  boolean numberIsEmpty(Number o){
        return isNull(o) || 0 == o.doubleValue();
    }

    public  boolean mapIsEmpty(Map o){
        return isNull(o) || 0 == o.size();
    }

    public  boolean isEmpty(Object o){
        if (isNull(o)){
            return  true;
        }
        if(o instanceof Map){
            return 0 == ((Map) o).size();
        }else if(o instanceof String){
            return 0 == ((String) o).length();
        }else if(o instanceof Number){
            return 0 == ((Number) o).doubleValue();
        }
        return false;

    }

}
